﻿/**
 * 
 * @file TreeWidgetLoad.h
 * @brief 载荷页面声明
 * @author LiBaojun (libaojunqd@foxmail.com)
 * @date 2024-10-12
 * 
 */
#ifndef _TREE_WIDGET_LOAD_H___
#define _TREE_WIDGET_LOAD_H___

#include "ControlPanel.h"

namespace GUI
{
    /**
     * @brief 分组页面
     * @author LiBaojun (libaojunqd@foxmail.com)
     * @date 2024-10-12
     */
    class GUIWIDGETAPI TreeWidgetLoad : public TreeWidgetPage
    {
    public:
        /**
         * @brief Construct a new Tree Widget Load object
         * @param[i]  parent         父对象
         * @author LiBaojun (libaojunqd@foxmail.com)
         * @date 2024-10-12
         */
        explicit TreeWidgetLoad(QWidget* parent = nullptr);
        /**
         * @brief Destroy the Tree Widget Load object
         * @author LiBaojun (libaojunqd@foxmail.com)
         * @date 2024-10-12
         */
        virtual ~TreeWidgetLoad() = default;
        /**
         * @brief 获取类型
         * @return TreeWidgetType 
         * @author LiBaojun (libaojunqd@foxmail.com)
         * @date 2024-10-12
         */
        TreeWidgetType getTreeWidgetType() override;
        /**
         * @brief    更新分组树菜单状态[不会更新渲染，只根据当前数据显示状态刷新菜单状态]
         * @author   liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2024-10-22
         */
        void updateLoadCaseTreeItemState();
        /**
         * @brief    更新节点名称通过数据ID
         * @param[i] objID
         * @return   void
         * @author   liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2025-02-12
         */
        void updateNodeName(int objID);
        /**
         * @brief    更新分组树
         * @return   void
         * @author   liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2025-02-12
         */
        void updateLoadCaseTree();

    protected:
    private:
        /**
         * @brief    初始化树形菜单
         * @return   void
         * @author   liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2024-10-22
         */
        void initTree();
        /**
         * @brief 树形菜单节点双击事件，子类重写实现
         * @param[i]  item           点击对象
         * @param[i]  column         列数
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2024-10-22
         */
        virtual void on_itemDoubleClicked(QTreeWidgetItem *item, int column) override;
        /**
         * @brief    树形菜单节点状态改变事件，子类重写实现
         * @param[i] item 点击对象
         * @param[i] state 改变之后的状态
         * @param[i] column 列数
         * @return   void
         * @author   liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2024-10-22
         */
        virtual void on_itemStateChanged(QTreeWidgetItem *item, bool state, int column) override;
        /**
         * @brief    树形菜单节点右键菜单事件，子类重写实现
         * @param[i] item 点击对象
         * @param[i] menu 右键菜单
         * @return   void
         * @author   liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2025-02-12
         */
        virtual void on_itemContextMenu(const QList<QTreeWidgetItem*>& item, QMenu* menu) override;
        /**
         * @brief    菜单栏添加工具
         * @param[i] objName 工程名称
         * @param[i] textName 文本名称
         * @param[i] iconFileName 图像路径
         * @return   void
         * @author   liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2025-02-12
         */
        void menuAddAction(QMenu* menu, QString objName, QString textName, QString iconFileName = QString());
        /**
         * @brief    获取对应数据的树节点
         * @param[i] objID
         * @param[i] item
         * @return   QTreeWidgetItem *
         * @author   liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2025-02-18
         */
        QTreeWidgetItem* getItemByObjID(int objID, QTreeWidgetItem * item);
    };
}


#endif
